///:HikariCPEx.java
package cn.weyoungstudio.hwes;

import cn.hutool.crypto.SecureUtil;
import cn.hutool.poi.excel.ExcelReader;
import cn.hutool.poi.excel.ExcelUtil;
import cn.weyoungstudio.hwes.dao.UserDao;
import cn.weyoungstudio.hwes.domain.User;
import cn.weyoungstudio.hwes.jdbc.common.SQLParameter;
import cn.weyoungstudio.hwes.jdbc.session.SqlSession;
import cn.weyoungstudio.hwes.jdbc.session.SqlSessionFactory;
import cn.weyoungstudio.hwes.jdbc.session.Transaction;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.sql.SQLException;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * sqlSession示例
 *
 * @author icechen1219
 * @date 2020/05/22
 */
public class Demo {
    static Logger log = LoggerFactory.getLogger(Demo.class);

    public static void main(String[] args) {
        SqlSessionFactory sqlSessionFactory = SqlSessionFactory.createSqlSessionFactory();
        try {
            ExcelReader reader = ExcelUtil.getReader(new File("excel/6班.xlsx"));
            List<User> users = reader.readAll(User.class);
            log.info(users.toString());
            UserDao userDao = new UserDao();
            for (User user : users) {
                user.setPassword(SecureUtil.md5(user.getUserNo()));
                userDao.add(user);
            }
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        } finally {
            sqlSessionFactory.close();
        }
    }
}
///:HikariCPEx.java
